<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<title>我的订单列表</title>
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/base.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/mod.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/list.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/page.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="{$staticHost}/static/css/competition.css" />
		<script src="{$staticHost}/static/js/jquery-1.8.3.min.js"></script>
		<script src="{$staticHost}/static/js/js.js"></script>
		<script src="{$staticHost}/static/js/mod.js"></script>
	</head>
	<body>
	<section id="empty" class="empty-box">
		<div>
			<img src="{$staticHost}/static/images/bg/image2_03-min.png" >
			<p>订单空空，快去参加比赛，获得奖励吧</p>
		</div>
	</section>

	<section id="con-box"></section>
	<script id="order" type="text/html">
		<%for(var i=0;i< result.length; i++) {%>
		<dl class="order-list line-gray-bottom pr">
			<a href="{$staticHost}/show/matchOrderInfo?order_id=<%=result[i].order_id%>" class="ddxq"></a>
			<dt>
				订单号：<%=result[i].order_id%>
				<%if(result[i].pay_status!=10){%>
					<span class="color-blue">
						<%if(result[i].status==1){%>等待发货<%}%>
						<%if(result[i].status==2){%>已发送<%}%>
						<%if(result[i].status==3){%>已取消<%}%>
						<%if(result[i].status==4){%>已完成<%}%>
					</span>
				<%}%>
				<%if(result[i].pay_status==10){%>
					<span class="color-red">未付款</span>
				<%}%>
			</dt>
			<% for(var w=0;w < result[i].goodsList.length;w++){ %>
			<dd>
				<img src="<%=result[i].goodsList[w].thumb%>"/>
				<p>
					<%=result[i].goodsList[w].goods_name %>
					<span class="color-blue">￥<%=result[i].goodsList[w].price %></span>
				</p>
				<p class="pt-10">
					<%=result[i].goodsList[w].introduce%>
					<span class="color_gray">X <%=result[i].goodsList[w].num %></span>
				</p>
			</dd>
			<% } %>
			<dd>
				<span class="color_gray">运费：<%=result[i].shipping_fee%></span><br/>
				<span class="f14">总计：<span class="color-blue">￥<%=result[i].total_fee%></span></span>
				<%if(result[i].pay_status==10){%>
				<p class="paybtn">
					剩余时间：
					<i id="t_d<%=result[i].order_id%>"></i> 天 
					<i id="t_h<%=result[i].order_id%>"></i> 小时 
					<i id="t_m<%=result[i].order_id%>"></i> 分
					<%if(result[i].pay_status==10){%>
						<a class="buy" href="javascript:void(0)" data-order-id="<%=result[i].order_id%>">付款</a>
					<%}%>
				</p>
				<%}%>
			</dd>
		</dl>
		<%}%>
		
	</script>
		
	</body>
	<script>
		var match_id  = "{$match_id}";
		$(function(){
			/***加载数据***/
			$.getJSON('{$staticHost}/orderWeb/getMatchOrderList',{match_id :match_id }, function(data, error) {
				console.log(data);
				var info=data.result;
				 //    var d = new Date(parseInt(info[x].stime) * 1000);
				// info[x].stime =d.getFullYear()+"."+xs(d.getMonth()+1)+"."+xs(d.getDate())+ " "+xs( d.getHours())+":"+xs(d.getMinutes());
				// function xs(n){ return n<10?("0"+n):n;}
				
				
				   // GetRTime()
					// 倒计时
				 if( data.result.length==0){
				   $("#con-box").css("display","none");
				   $("#empty").show();
				   // window.history.back()
				    setTimeout(" window.history.back()",5000); 
				}

				var html = template('order', data);
				document.getElementById('con-box').innerHTML = html;

				if(info.length > 0) {
					for(var x in info) {
						if(info[x].pay_status==10) {
							GetRTime()
							
						}
					}
				}
				// 倒计时mokuuai
				var timestamp = parseInt((new Date()).getTime()/1000)
				function GetRTime(){
				  	var Tt =  info.stime;
				  	var t =Tt - timestamp;
				    var d=0, h=0, m=0;
				    if(t>=0){
				      d=Math.floor(t/60/60/24);
				      h=Math.floor(t/60/60%24);
				      m=Math.floor(t/60%60);

				    }else{
				     	clearInterval(id);
				     	$(".paybtn").hide();
					}
					$("#t_d"+data.result[x].order_id).html(d);
				    $("#t_h"+data.result[x].order_id).html(h);
				    $("#t_m"+data.result[x].order_id).html(m);
				    console.log(info[x].stime+"活动开始时间")
				    console.log(info[x].addtime+"下单时间")

				   }
				   var id=setInterval(GetRTime,0);
				$(".buy").click(function(){
                    var order_id = $(this).data('order-id')
                    $.getJSON('{$staticHost}/orderWeb/matchOrderPay',{order_id:order_id}, function(data){
                        if(data.status && data.status.code==200){
	                        window.location.href = data.result.pay_host + '?' + data.result.pay_str
	                    }
	                })
	            })
	            // 付款
	            $(".ddxq").click(function(){
                    var order_id = $(this).data('order-id')
                    $.getJSON('{$staticHost}/orderWeb/matchOrderPay',{order_id:order_id}, function(data){
                        if(data.status && data.status.code==200){
	                        window.location.href = data.result.pay_host + '?' + data.result.pay_str
	                    }
	                })
	            })
	            // 跳转订单详情

			})
        });
	</script>
<script type="text/javascript" src="http://b3.hoopchina.com.cn/web/module/dace/m/m_dace.js"></script>
<!--{template 'show/web-footer'}-->

